package com.fsnbigdata.web;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.roo.addon.web.mvc.controller.annotations.responses.json.RooJSON;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fsnbigdata.service.api.AnimalConservationService;
import com.fsnbigdata.service.api.EcosystemService;
import com.fsnbigdata.service.api.EnterpriseService;
import com.fsnbigdata.service.api.OrganismService;
import com.fsnbigdata.service.api.ParkService;
import com.fsnbigdata.service.api.ProductService;
import com.fsnbigdata.service.api.SpecimenService;
import com.fsnbigdata.service.api.VegetationService;


@RequestMapping("/api/count")
@RooJSON
@RestController
public class CountController {
	@Autowired
	private OrganismService organismService;
	@Autowired
	private SpecimenService specimenService;
	@Autowired
	private ParkService parkService;
	@Autowired
	private EcosystemService ecosystemService;
	@Autowired
	private AnimalConservationService animalConservationService;
	@Autowired
	private VegetationService vegetationService;
	@Autowired
	private EnterpriseService enterpriseService;
	@Autowired
	private ProductService productService;
	
	@CrossOrigin
	@GetMapping("/getCount")
	public Map<String, Long> getCount(){
		Map<String, Long> map = new HashMap<String, Long>();
		Long organismCount = organismService.count();
		Long specimenCount = specimenService.count();
		Long parkCount = parkService.count();
		Long ecosystemCount = ecosystemService.count();
		Long animalConservationCount = animalConservationService.count();
		Long vegetationCount = vegetationService.count();
		Long enterpriseCount = enterpriseService.count();
		Long productCount = productService.count();
		map.put("organismCount", organismCount); //物种
		map.put("specimenCount", specimenCount); //标本
		map.put("parkCount", parkCount); //植物园
		map.put("ecosystemCount", ecosystemCount); //生态环境
		map.put("animalConservationCount", animalConservationCount); //保育库
		map.put("vegetationCount", vegetationCount); //植被库
		map.put("enterpriseCount", enterpriseCount); //企业
		map.put("productCount", productCount); //产品
		return map;
	}
}
